# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://doc.scrapy.org/en/latest/topics/item-pipeline.html
import pymysql

class DoubanPipeline(object):
    def __init__(self):
        self.conn=pymysql.connect(
            host = 'localhost',
            user="root",
            password="12345678",
            charset="utf8mb4",
            database="bole"

        )
    def process_item(self, item, spider):
        cursor = self.conn.cursor()
        sql = 'insert into article (`title`)values("{}")'.format(item._values.get("name", ""))
        cursor.execute(sql)
        self.conn.commit()
        cursor.close()
        return item
